home *** CD-ROM | disk | FTP | other *** search
-
- export position
- export prev
- export next
- export parent
- export childcount
- export text
- export encode5
- export init_encode5
- export output5
- export insert_node
- export get_next_match
- export in_split
- export output_pos
- export output_mask
- import buf
- import c_freq
- import p_freq
- import level
- import infile
- import blocksize
- import buffered
- import send_block
- import fread_crc
- import start_huf
- import end_huf
- import ProcInd
- import shipout
-
- BUFSIZ set 16384
-
- MODULE encode5
-
- import remainder,pos,printcount,l_mpos
- import get_next_match
- TEXT
-
- ;encode5:
- movem.l D3-D7/A2-A6,-(SP)
- lea pos(PC),A6 ; pos GLOBAL!
- move.l infile(PC),A1 ; infile
- move.w #$2100,D0 ; DICSIZ+MAXMATCH
- move.l text(PC),A0 ; text
- lea $2000(A0),A0 ; text[DICSIZE]
- bsr fread_crc ; fread_crc
- move.w D0,remainder-pos(a6) ;+ remainder=fread_crcx
- ext.l d0
- add.l d0,printcount-pos(a6)
- cmp.w #$2000,d0
- blt.s ind2
- proc_ind2: move.l blocksize(pc),d0
- cmp.l printcount(pc),d0
- bgt.s enc51
- sub.l d0,printcount-pos(a6)
- ind2: bsr ProcInd
- bra.s proc_ind2
- enc51:; move.w #$FFFF,D0
- and.l D0,D1
- and.l D0,D2
- and.l D0,D3
- and.l D0,D4
- and.l D0,D5
- and.l D0,D6
- and.l D0,D7
-
- moveq #0,d7 ; matchlen=0
- moveq #0,D0 ;+? 0
- move.l parent-pos(a6),a2;+
- move.l prev-pos(a6),a3 ;+
- move.l next-pos(a6),a4 ;+ a4 = next[] GLOBAL!
- move.w #$2000,(A6) ; pos=DICSIZ
- ; movem.w D4-d5,-(SP) ;+
- move.w D4,-(SP) ;+
- bsr insert_node ; insert_node
- ; movem.w (sp)+,D4-d5 ;+
- move.w (sp)+,D4 ;+
- bra.b encod7 ; while
- ; --------------------------------------;
- encod1: move.w d7,D4 ; lastmatchlen=matchlen
- ; move.w d6,D5 ; lastmatchpos=matchpos
- move.w d6,l_mpos-pos(A6) ; lastmatchpos=matchpos
- bsr get_next_match ; get_next_match
- cmp.w remainder(PC),D7 ;+ if (matchlen>remainder)
- ble.b encod2
- move.w remainder(PC),d7 ;+ matchlen=remainder
- encod2: cmp.w d7,D4 ; if (matchlen>lastmatchlen
- blt.b encod3 ; ||
- cmp.w #3,D4 ; lastmatchlen<THRESHOLD)
- bge.b encod4
- encod3: move.w (A6),D0 ; pos
- move.l text(PC),A0 ;+ text
- moveq #0,D1
- move.b -1(A0,D0.w),D1 ; text[pos-1]
- moveq #0,D3 ; 0
- bsr output5 ; output5(..)
- bra.b encod8
- ; --------------------------------------;
- encod4: move.w (A6),D3 ; pos
- ; sub.w D5,D3 ; pos-lastmatchpos
- sub.w l_mpos(PC),D3 ; pos-lastmatchpos
- subq.w #2,D3 ; pos-lastmatchpos-2
- and.w #$1FFF,D3 ; (pos-lastmatchpos-2)&(UCHAR_MAX+1-THRESHOLD)
- move.w D4,D1 ; lastmatchlen
- add.w #$FD,D1 ; lastmatchlen+UCHAR_MAX+1-THRESHOLD
- bsr output5 ; output5
- subq.w #1,D4 ;
- ble.b encod7 ; while (--lastmatchlen>0)
- encod5: bsr get_next_match ; get_next_match
- subq.w #1,D4 ;
- bgt.b encod5
- ; --------------------------------------;
- encod7: cmp.w remainder(PC),D7;+ if (matchlen>remainder)
- ble.b encod8 ;
- move.w remainder(PC),d7;+ matchlen=remainder
- ; --------------------------------------;
- encod8: move.w remainder(PC),D0;+ remainder
- bgt.b encod1 ; <0
- ; --------------------------------------;
- bsr end_huf ; end_huf
- tst.b buffered
- bne.b encod11
- bsr shipout
-
- encod11: movem.l (SP)+,D3-D7/A2-A6
- rts
-
- ENDMOD
-
- align
-
- MODULE output5 ;p.w in D3 c.w in D1
-
- IMPORT output_mask,output_pos,cpos
-
- TEXT
- move.w output_pos(pc),D0 ;+
- move.l buf(PC),A1 ;+
- adda.l D0,A1 ;.l?
- subq.w #1,output_mask-pos(A6)
- ; lsr.w output_mask-pos(a6) ; output_mask >> 1
- ; bne.b out5_2 ; if {output_mask = 0) {
- bpl.b out5_2 ; if {output_mask = 0) {
- ; move.w #$80,output_mask-pos(a6) ; output_mask=1U <<(CHAR_BIT-1)
- move.w #7,output_mask-pos(a6) ; output_mask=1U <<(CHAR_BIT-1)
- cmp.w #BUFSIZ-$18,D0 ; -3*CHAR_BIT+bufsiz
- bcs.b out5_1 ;
- move.w d1,-(sp) ;
- bsr send_block ; send_block
- moveq #0,D1
- moveq #0,D2
- move.w (sp)+,d1 ;
- move.l buf(PC),A1 ;+
- moveq #0,D0 ;+ outputpos=0
- ; D0=output_pos=0
- out5_1: move.w D0,cpos-pos(A6) ; cpos=output_pos
- clr.b (A1)+ ; buf[cpos]=0
- addq.w #1,D0 ; output_pos++
- out5_2: move.b D1,(A1)+ ;+ buf[output_pos]=c
- addq.w #1,D0 ; output_pos++
- add.w D1,D1 ; c*2
- lea c_freq,A0 ; c_freq
- addq.w #1,0(A0,D1.w) ; c_freq[c]++
- cmp.w #$0200,D1 ; if (c>=(1U<<CHAR_BIT)
- bcs.b out5_5 ;
- ; move.b output_mask+1-pos(a6),D1 ; output_mask
- move.w output_mask-pos(a6),D1 ; output_mask
- ;;; moveq #0,D2 ;
- move.w cpos(PC),D2 ; cpos
- sub.w D0,D2 ;
- ; or.b D1,0(A1,D2.w) ;+ buf[cpos] != output_mask
- bset.b D1,0(A1,D2.w) ;+ buf[cpos] != output_mask
- move.w D3,D1 ; p
- lsr.w #8,D1 ; p>>CHAR_BIT
- move.b D1,(A1)+ ; buf[output_pos++]=p>>CHAR_BIT
- bne.b nout_5_1 ;+ dann ...
- move.b D3,(A1)+ ;+ buf[output_pos++]=p
- addq.w #2,D0 ;+ output_pos++&++
- moveq #16,D1 ; *TT -> move.w d3,...*
- tst.w D3 ;.W!!!!
- dbeq D1,out5_3 ;
- bra.b out5_4 ; while (p) {
- out5_3: lsr.w #1,D3 ; p>>=1
- dbeq D1,out5_3 ;+
- out5_4: add.w D1,D1 ; 2*2
- neg.w D1 ;
- lea p_freq,A0 ; p_freq
- addq.w #1,32(A0,D1.w) ;+ p_freq[c]++
- out5_5: move.w d0,output_pos-pos(a6) ;sichern
- rts
-
- nout_5_1:
- move.b D3,(A1)+ ;+ buf[output_pos++]=p
- addq.w #2,D0 ;+ output_pos++&++
- ; moveq #8,D2 ; *TT -> move.w d3,...*
- moveq #7,D2 ; *TT -> move.w d3,...*
- ; tst.w D1 ;.W!!!!
- ; dbeq D2,nout5_3 ;
- ; bra.b nout5_4 ; while (p) {
- nout5_3: lsr.b #1,D1 ; p>>=1
- dbeq D2,nout5_3 ;+
- nout5_4: add.w D2,D2 ; 2*2
- neg.w D2 ;
- lea p_freq,A0 ; p_freq
- addq.w #1,32(A0,D2.w) ;+ p_freq[c]++
- move.w d0,output_pos-pos(a6) ;sichern
- rts
-
-
-
- ENDMOD
-
- align
-
- MODULE insert_node
-
- IMPORT avail
- EXPORT insert_n
-
- TEXT
- insert_n:
- ;insert_node: ;
- move.l position-pos(a6),A1 ;+
- subq.w #4,d7 ;+ if (matchl >= 4)
- blt.b inode7 ;
- addq.w #3,d7 ;+ matchl--
- moveq #1,D4 ;
- add.w d6,D4 ;
- or.w #$2000,D4 ; r=(matchpos+1)|DICSIZ
- ; --------------------------------------;
- move.l D4,D0 ;+ r (.l -> D0 upper = 0)
- add.w D0,D0 ;+ r * 2
- move.w 0(A2,D0.l),D5 ;+ q=parent[r]
- bne.b inode1_ ;+ }
- inode1: move.w 0(A4,D0.l),D4 ; r=next[r]
- move.w D4,D0 ; r
- add.w D0,D0 ; r * 2
- move.w 0(A2,D0.l),D5 ; q=parent[r]
- beq.b inode1 ; }
- inode1_: move.l level(PC),A0 ;
- cmp.b 0(A0,D5.w),d7 ;+ level[q] }
- bhi.b inode3_ ;+
- inode3: move.w D5,D4 ; r = q
- add.w D5,D5 ; q * 2
- move.w 0(A2,D5.l),D5 ; q=parent[q]
- ; move.b 0(A0,D5.w),D0 ; level[q]
- ; cmp.b D0,d7 ;+ }
- cmp.b 0(A0,D5.w),D7 ; level[q]
- bls.b inode3 ;+
- inode3_: move.w D5,D0 ; t = q
- add.w D0,D0 ;+ t * 2
- move.w 0(A1,D0.l),D1 ;+ position[t]
- bge.b inode5_ ;+ while (position[t] < 0) {
- move.w (a6),d2 ;+ pos
- inode5: move.w d2,0(A1,D0.l) ;+ position[t] = pos
- move.w 0(A2,D0.l),D0 ; t=parent[t]
- add.w D0,D0 ;+ t * 2
- move.w 0(A1,D0.l),D1 ;+ while(position[t]<0)
- blt.b inode5 ; }
- inode5_: cmp.w #$4000,D0 ; if (t < DICSIZ) {
- bge.s inode9 ;
- move.w (A6),D2 ; pos
- or.w #$8000,D2 ; pos | PERC_FLAG
- move.w D2,0(A1,D0.l) ;+ position[t] = pos | PERC_FLAG
- bra.b inode9 ;
- ; --------------------------------------:
- inode7: move.w (A6),D0 ; pos
- move.l text-pos(a6),A0 ;
- moveq #0,d5 ;
- move.b 0(A0,D0.w),D5 ; q = text[pos]
- add.w #$2000,D5 ; + DICSIZE
- moveq #0,D4 ;+
- move.b 1(A0,D0.w),d7 ; c = text[pos+1]
- move.b D7,D4 ;+
- ; --------------------------------------; beg child
- lsl.w #4,D4 ;
- add.w D5,D4 ;
- add.w #$4000,D4 ; r=HASH(q,c)
- add.w D4,D4 ;+ 2*r
- move.w D5,(A2) ; parent[NIL]=q
- nchild1: move.w 0(A4,D4.l),D4 ;+ r=next[r]
- add.w D4,D4 ;+ 2*r
- cmp.w 0(A2,D4.l),D5 ; while (parent[r] != q)
- bne.b nchild1 ;
- ; --------------------------------------;
- lsr.w #1,D4
- bne.b inode8 ; if ((r=child(q,c)) == NIL)
- ; --------------------------------------;
- move.w (A6),D2 ; pos
- ;D4 ist 0! moveq #0,d4 ;d7 upper = 0?
- move.b d7,D4 ; c
- ; --------------------------------------; makechild
- lsl.w #4,D4 ; c<<DICBIT-9
- add.w d5,D4 ; p+c
- add.w #$4000,D4 ; ((p)+((c)<<(DICBIT-9))+(DICSIZ*2)
- move.w D4,D1 ; h
- add.w D4,D4 ;+ 2*h
- move.w 0(A4,D4.l),D3 ; t=next[h]
- move.w D2,0(A4,D4.l) ; next[h]=r
- move.w D2,D4 ; r
- add.w D4,D4 ;+ 2*r
- move.w D3,0(A4,D4.l) ; next[r]=t
- ; ext.l D3 ; t?
- add.w D3,D3 ;+ 2*t
- move.w D2,0(A3,D3.l) ; prev[t]=r
- move.w D1,0(A3,D4.l) ; prev[r]=h
- move.w d5,0(A2,D4.l) ; parent[r]=q
- move.l childcount-pos(a6),A0 ;
- addq.b #1,0(A0,d5.w) ; childcount[q]++
- ; --------------------------------------; makechild
- moveq #1,d7 ;+ matchl=1
- rts ; return
- ; --------------------------------------;
- inode8: moveq #2,d7 ; matchl=2
- inode9: cmp.w #$2000,D4 ; if (r>DICSIZ)
- blt.b inode10 ;
- move.w #$0100,d2 ; j = MAXMATCH
- move.w D4,d6 ; matchpos=r
- bra.b inode11 ;
- inode10: move.l level(PC),A0 ;
- moveq #0,d2 ;
- move.b 0(A0,D4.w),d2 ; r=level[r]
- move.w D4,D0 ; r
- add.w D0,D0 ; r*2
- ; move.l position-pos(a6),A1 ;
- move.w 0(A1,D0.l),D1 ; position[r]
- and.w #$7FFF,D1 ; position[r] & ~PERC_FLAG
- move.w D1,d6 ; matchpos=position[r] & ~ PERC_FLAG
- inode11: move.w (A6),D0 ;+ pos
- cmp.w D0,D6 ;+
- blt.b inode12 ; if (matchpos>=pos)
- subi.w #$2000,d6 ; matchpos-=DICSIZE
- ; --------------------------------------;
- inode12: add.w d7,D0 ; pos+matchl
- move.l text-pos(a6),A0 ; text
- lea 0(a0,d0.w),a5
- move.w d6,D1 ; matchpos
- add.w d7,D1 ; matchpos+matchl
- lea 0(a0,d1.l),a0 ; t2=text[matchpos+matchl]
- move.w d2,d0
- sub.w d7,d0
- beq.b inode14
- subq.w #1,d0
- inode13: cmpm.b (A5)+,(A0)+ ;
- dbne d0,inode13 ; matchl<j
- bne in_split
- ; neg.w d0
- not.w d0 ;
- add.w d2,d0
- ; subq.w #1,d0
- move.w d0,d7
- ; --------------------------------------;
- inode14: cmp.w #$0100,d7 ; if matchl>MAXMATCH
- bge.b inode17 ; break
- ; --------------------------------------;
- ; move.w D4,D0 ; r
- move.w D4,D5 ; q=r
- ; add.w D0,D0 ;+ 2*r
- add.w D4,D4 ;+ 2*r
- ; move.l position-pos(a6),A0 ;
- ; move.w (A6),0(A0,D0.l) ; position[r]=pos
- move.w (A6),0(A1,D4.l) ; position[r]=pos
- ; move.w D4,D5 ; q=r
- moveq #0,d4 ;+
- move.b (A5),D4 ;+ *t1
- ; --------------------------------------; beg child
- lsl.w #4,D4 ;+
- add.w D5,D4 ;+
- add.w #$4000,D4 ;+ h=HASH(q,c)
- add.w D4,D4 ;+ 2*h
- move.w D5,(A2) ; parent[NIL]=q
- nchild2: move.w 0(A4,D4.l),D4 ;+ r=next[r]
- add.w D4,D4 ;+ 2*r
- cmp.w 0(A2,D4.l),D5 ;+ while (parent[r] != NIL)
- bne.b nchild2 ;
- ; --------------------------------------; end child
- lsr #1,D4
- bne.b inode16 ; if ((r=child(q,*t1)) != NIL) {
- move.w (A6),D2 ; pos
- ;D4 ist 0! moveq #0,d4
- move.b (A5),D4 ; *t1
- ; --------------------------------------; makechild
- lsl.w #4,D4 ; c<<DICBIT-9
- add.w d5,D4 ; p+c
- add.w #$4000,D4 ; ((p)+((c)<<(DICBIT-9))+(DICSIZ*2)
- move.w D4,D1 ; h
- add.w D4,D4 ;+ 2*h
- ;; moveq #0,D3 ;+?
- move.w 0(A4,D4.l),D3 ; t=next[h]
- move.w D2,0(A4,D4.l) ; next[h]=r
- move.w D2,D4 ; r
- add.w D4,D4 ;+ 2*r
- move.w D3,0(A4,D4.l) ; next[r]=t
- add.w D3,D3 ; 2*t
- move.w D2,0(A3,D3.l) ; prev[t]=r
- move.w D1,0(A3,D4.l) ; prev[r]=h
- move.w d5,0(A2,D4.l) ; parent[r]=q
- move.l childcount-pos(a6),A0 ;
- addq.b #1,0(A0,d5.w) ; childcount[q]++
- rts ; return
- ; --------------------------------------;
- inode16: addq.w #1,d7 ; matchl++
- bra inode9 ; } /* for */
- ; --------------------------------------;
- inode17: move.w (a6),d3
- move.w D4,D0 ; r
- add.w D0,D0 ;+ 2*r
- move.w 0(A3,D0.l),D1 ; t = prev[r]
- move.w d3,D2 ; pos
- add.w D2,D2 ;+ 2*pos
- move.w D1,0(a3,D2.w) ; prev[pos]=t
- add.w D1,D1 ;+ 2*t
- move.w d3,0(A4,D1.l) ; next[r] = pos
- move.w 0(A4,D0.l),D1 ; t=next[r]
- move.w D1,0(A4,D2.l) ; next[pos]=t
- add.w D1,D1 ;+ 2*t
- move.w d3,0(a3,D1.l) ; prev[t] = pos
- move.w D5,0(A2,D2.l) ; parent[pos]=q
- clr.w 0(A2,D0.l) ; parent[r] = NIL
- move.w d3,0(A4,D0.l) ; next[r]=pos
- rts ;
-
- ENDMOD
-
- align
-
- MODULE in_split
-
- ;in_split:
- not.w d0 ;+
- add.w d2,d0
- move.w d0,d7 ;matchlen=matchl;
- move.w D4,D1 ; split(r)
- ; --------------------------------------; split
- movem.l (a6),D3/A0/A5 ; new=avail + pos + &childcount
- ; + &text
- move.w D3,D2 ; new
- add.w D2,D2 ;+ new * 2
- move.w 0(A4,D2.l),avail-pos(a6) ; avail=next[new]
- move.b #2,0(A0,D3.w) ;+ childcount[new] = 0+1+1
- add.w D1,D1 ;+ old * 2
- move.w 0(A3,D1.l),D0 ; t = prev[old]
- move.w D0,0(A3,D2.l) ; prev[new] = t
- add.w D0,D0 ;+ t * 2
- move.w D3,0(A4,D0.l) ; next[t] = new
- move.w 0(A4,D1.l),D0 ; t=next[old]
- move.w D0,0(A4,D2.l) ; next[new] = t
- add.w D0,D0 ;+ t * 2
- move.w D3,0(A3,D0.l) ; prev[t] = new
- move.w 0(A2,D1.l),0(A2,D2.l) ; parent[new] = parent[old]
- move.w (a6),0(A1,D2.l) ; positon[new]=pos
- ;(a6) steht in d3 high word ....
- move.l level(PC),a1 ; ab hier nicht mehr position
- move.b d7,0(A1,d3.w) ; level[new]=matchlen
- ; makechil(new,text[matchpos+matchlen],old)
- move.w d6,D0 ;
- add.w d7,D0 ;
- moveq #0,d2 ;
- move.b 0(A5,D0.w),D2 ;
- ; --------------------------------------;
- lsl.w #4,D2 ; c<<DICBIT-9
- add.w D3,D2 ; p+c
- add.w #$4000,D2 ; ((p)+((c)<<(DICBIT-9))+(DICSIZ*2)
- move.w D2,D0 ; h
- add.w D2,D2 ;+ 2*h
- move.w 0(A4,D2.l),d5 ; t=next[h]
- move.w D4,0(A4,D2.l) ; next[h]=r
- move.w d5,0(A4,D1.l) ; next[r]=t
- add.w d5,d5 ;+ 2*t
- move.w D4,0(A3,d5.l) ; prev[t]=r
- move.w D0,0(A3,D1.l) ; prev[r]=h
- move.w D3,0(A2,D1.l) ; parent[r]=q
- ; makechild(new,text[pos+matchlen],pos)
- swap d3
- move.w d3,D2
- add.w d7,D3
- moveq #0,d4
- move.b 0(A5,D3.w),D4 ;+ text[pos+matchlen]
- swap d3
- ; --------------------------------------; makechild
- lsl.w #4,D4 ; c<<DICBIT-9
- add.w D3,D4 ; p+c
- add.w #$4000,D4 ; ((p)+((c)<<(DICBIT-9))+(DICSIZ*2)
- move.w D4,D1 ; h
- add.w D4,D4 ;+ 2*h
- move.w 0(A4,D4.l),D0 ; t=next[h]
- move.w D2,0(A4,D4.l) ; next[h]=r
- move.w D2,D4 ; r
- add.w D4,D4 ;+ 2*r
- move.w d0,0(A4,D4.l) ; next[r]=t
- add.w d0,d0 ;+ 2*t
- move.w D2,0(A3,d0.l) ; prev[t]=r
- move.w D1,0(A3,D4.l) ; prev[r]=h
- move.w D3,0(A2,D4.l) ; parent[r]=q
- moveq #0,D3
- rts
- ENDMOD
-
- align
-
- MODULE get_next_match
-
- EXPORT gnext1,get_next
-
- IMPORT my_cnt,st_save
-
- TEXT
-
- get_next:
- ;get_next_match:
- subq.w #1,remainder-pos(a6)
- ; addq.w #1,(a6)
- ; cmpi.w #$4000,(a6)
- cmpi.w #$3fff,(a6)
- ; bne.b gnext1
- beq get_n_m_1
- addq.w #1,(a6)
- ;gnext1: movem.w D4-d5,-(sp)
- gnext1: move.w D4,-(sp)
- ;GLOBAL move.l parent-pos(a6),a2
- ;GLOBAL move.l next-pos(a6),a4
- ;GLOBAL move.l prev-pos(a6),a3
- ;eventuell D6 const #$2000
- ;delete_node:
- ;;; moveq #0,d2 ;+
- move.w (a6),d2 ; d2=pos
- ; move.w d2,D1 ; pos
- move.l d2,D1 ;+ pos
- add.w D1,D1 ; 2*pos
- ;? move.w 0(A2,D1.l),D0 ; if (parent[pos] == NIL)
- ;;; moveq #0,d3 ;+
- move.w 0(A2,D1.l),D3 ;+ if ((r=parent[pos]) == NIL)
- beq.b dnode9_ ; return
- ; moveq #0,d3 ;+
- move.w 0(A3,D1.w),D5 ; r' = prev[pos]
- ; move.w 0(A3,D1.w),D3 ; r = prev[pos]
- move.w 0(A4,D1.w),D4 ; s = next[pos]
- ; move.l D3,D0 ;+ r
- move.l D5,D0 ;+ r'
- add.w D0,D0 ; 2 * r
- move.w D4,0(A4,D0.l) ; next[r]=s
- ; move.w D4,D0 ; s
- ; add.w D0,D0 ;+ s * 2
- add.w D4,D4 ;+ s * 2
- ; move.w D3,0(A3,D0.w) ;+ prev[s] = r
- move.w D5,0(A3,D4.w) ;+ prev[s] = r'
- ; move.w 0(A2,D1.w),D3 ;+ r = parent[pos]
- ; clr.w 0(A2,D1.l) ; parent[pos] = NIL
- clr.w 0(A2,D1.l) ; parent[pos] = NIL
- cmp.w #$2000,D3 ; if (r >= DICSIZ)
- ; bge dnode9 ;
- blt.b dnodea_ ;
- dnode9_:
- ; **************************************************************************
- bsr insert_node
- ; movem.w (sp)+,d4-d5
- move.w (sp)+,d4
- rts
- dnodea_: move.l childcount-pos(a6),A1 ; ||
- adda.l D3,A1 ;+ (long ist schneller!)
- subq.b #1,(A1) ;+ --childcount[r]
- cmpi.b #1,(A1) ;+ > 1)
- bhi.b dnode9_ ; return
- move.l position-pos(a6),A1 ; position
- move.w D3,D1 ; r
- add.w D1,D1 ;+ r * 2
- move.w 0(A1,D1.w),D5 ; t=position[r]
- and.w #$7FFF,D5 ; & ~PERC_FLAG
- cmp.w d2,D5 ; if (t>=pos)
- blt.b dnode1 ;
- sub.w #$2000,D5 ; t-=DICSIZ
- ;---------------------------------------;
- dnode1: move.w D5,D4 ; s = t
- move.w d5,a0
- move.w 0(A2,D1.l),D0 ; q = parent[r]
- add.w d0,d0 ; q*2
- move.w 0(A1,D0.l),d5 ;+ u=position[q]
- bclr #15,D5 ;+
- beq.b dnode5_
- dnode2: cmp.w d2,d5 ; if (u>=pos)
- blt.b dnode3 ;
- sub.w #$2000,d5 ; u-=DICSIZ
- dnode3: cmp.w d5,D4 ; if (u>=s)
- bge.b dnode4 ;
- move.w d5,D4 ; s=u
- dnode4: move.w D4,D1 ; s
- or.w #$2000,D1 ; |DICSIZ
- move.w D1,0(A1,D0.l) ; position[q] = s | DICSIZ
- move.w 0(A2,D0.l),D0 ; q=parent[q]
- add.w d0,d0 ; q*2
- ;dnode5:
- move.w 0(A1,D0.l),d5 ; u=position[q]
- ; move.w d5,D1 ; u
- ; and.w #$8000,D1 ; parent[r] & PERC_FLAG
- bclr #15,D5 ;+
- bne.b dnode2 ; }
- dnode5_:
- ; end_while ------------------------;
- cmp.w #$4000,D0 ; if (q<DICISZ}
- bge.b dnode8 ; {
- cmp.w d2,d5 ; if (u>=pos)
- blt.b dnode6 ;
- sub.w #$2000,d5 ; u-=DICSIZ
- dnode6: cmp.w d5,D4 ; if (u>s)
- bge.b dnode7 ;
- move.w d5,D4 ; s=u
- dnode7: or.w #$A000,D4 ; s|DICSIZ|PERC_FLAG
- move.w D4,0(A1,D0.l) ; position[q]=s|DICSIZ|PERC_FLAG
- ;---------------------------------------;
- dnode8: move.l level(PC),A1 ; level
- moveq #0,D0 ;+
- move.b 0(A1,D3.w),D0 ; level[r]
- add.w a0,D0 ; level[r]+t
- move.l text-pos(a6),A1 ; text
- moveq #0,d4 ;+
- ; move.b 0(A1,D0.w),D2 ; text[level[r]+t]
- move.b 0(A1,D0.w),D4 ; text[level[r]+t]
- ; --------------------------------------; beg child
- ; and.l #$ff,d2 ;obere 16 bit immer = 0 !
- ; moveq #0,D2 ;
- ; move.b D1,D2 ;
- ; lsl.w #4,D2 ;
- lsl.w #4,D4 ;+
- ; add.w D3,D2 ;
- add.w D3,D4 ;+
- ; add.w #$4000,D2 ; h=HASH(q,c)
- add.w #$4000,D4 ;+ h=HASH(q,c)
- add.w D4,D4 ;+ 2*h
- move.w d3,(A2) ; parent[NIL]=q
- dchild1: move.w 0(A4,D4.l),D4 ;+ r=next[r]
- add.w D4,D4 ; 2*r
- cmp.w 0(A2,D4.l),D3 ; while (parent[r] != NIL)
- bne.b dchild1 ;
- move.w D4,D0 ;+ s*2
- lsr.w #1,D4
- ; --------------------------------------; end child
- move.w 0(A3,D0.w),D5 ; t=prev[s]
- move.w 0(A4,D0.w),D2 ; u=next[s]
- move.w D5,D1 ; t
- add.w D1,D1 ; t * 2
- move.w D2,0(A4,D1.l) ; next[t] = u
- add.w D2,D2 ; u * 2
- move.w D5,0(A3,D2.w) ; prev[u] = t
- move.w D3,D2 ; r
- add.w D2,D2 ; r * 2
- move.w 0(A3,D2.w),D5 ;+ t = prev[r]
- move.w D5,0(A3,D0.w) ;+ prev[s] = t
- add.w D5,D5 ; t * 2
- move.w D4,0(A4,D5.l) ; next[t] = s
- move.w 0(A4,D2.l),D5 ; t=next[r]
- move.w D5,0(A4,D0.l) ;+ next[s]=t
- add.w D5,D5 ; t * 2
- move.w D4,0(A3,D5.w) ; prev[t]=s
- move.w 0(A2,D2.l),0(A2,D0.l) ; parent[s]=parent[r]
- clr.w 0(A2,D2.l) ; parent[r]=NIL
- move.w avail-pos(a6),0(A4,D2.l) ; next[r]=avail
- move.w D3,avail-pos(a6) ; avail=r
- dnode9:
- ; **************************************************************************
- bsr insert_node
- ; movem.w (sp)+,d4-d5
- move.w (sp)+,d4
- rts
- get_n_m_1:
- ; move.l #$2100,D0
- move.l text-pos(a6),A0
- lea $2000(A0),A0
- ; lea $2000(A0),A1
- ;++++++++++++++++
- movem.l D1-D7/A2-A6,-(a7) ;regs für gnext1 mit?
- move.l A7,st_save ;
- move #7,my_cnt
- nxt_cpy:
- REPT 20
- movem.l (a0)+,D0-D7/A1-A7
- movem.l D0-D7/A1-A7,-$203c(a0)
- ENDM
- subq.w #1,my_cnt
- bne nxt_cpy
- movem.l (a0)+,D0-D7/A1-A4
- movem.l D0-D7/A1-A4,-$2030(a0)
- move.l st_save(PC),A7
- movem.l (a7)+,D1-D7/A2-A6
- ; bsr memcpy
- ;++++++++++++++++++
- move.l infile(PC),A1
- move.w #$2000,D0
- move.l text-pos(a6),A0
- lea $2100(A0),A0
- bsr fread_crc
- add.w D0,remainder-pos(a6)
- move.w #$2000,pos-pos(A6)
- ext.l d0
- add.l d0,printcount-pos(a6)
- cmp.w #$2000,d0
- blt.s ind1
- proc_ind1: move.l blocksize(pc),d0
- cmp.l printcount(pc),d0
- bgt.s gnext1_
- sub.l d0,printcount-pos(a6)
- ind1: bsr ProcInd
- bra.s proc_ind1
-
- gnext1_:
- moveq #0,D0
- moveq #0,D1
- moveq #0,D2
- bra gnext1
-
- ENDMOD
-
- align
-
- MODULE init_encode5
-
- EXPORT init_en
-
- init_en:
- ;init_encode5:
- ; bsr allocate_memory
- ; bsr init_slide
- movem.l D2-D7/A2-A6,-(A7)
- moveq #0,D0
- lea pos(pc),A6
- move.w d0,output_pos-pos(a6) ;hier im Modul
- move.w d0,output_mask-pos(a6) ;da Adressierung schneller
- move.l d0,printcount-pos(a6)
- move.w #1,avail-pos(a6)
- moveq #0,D1
- moveq #0,D2
- moveq #0,D3
- moveq #0,D4
- moveq #0,D5
- moveq #0,D6
- moveq #0,D7
- move.l D0,A0
- move.l D0,A1
- move.l D0,A2
- move.l D0,A3
- move.l D0,A4
- move.l D0,A5
- move.l position(PC),A6
- lea ($2100*2)(A6),A6
- REPT 9
- movem.l D0-D7/A0-A5,-(A6) ;
- ENDM
- movem.l D0-D1,-(A6) ; (9*14+4)*2=256
- move.l parent(PC),A6
- adda.l #(($2000*2)*2),A6
- move.w #78-1,D7
- qdel_1:
- REPT 4
- movem.l D0-D6/A0-A5,-(A6) ;
- ENDM
- dbra D7,qdel_1
- REPT 3
- movem.l D0-D6/A0-A5,-(A6) ;
- ENDM
- move.w D0,-(A6) ; (315*13+1)*2=$2000
- move.l next(PC),A6
- adda.l #$70F0*2,A6 ; 25056 Bytes = 0x61E0
- move.w #60-1,D7
- qdel_2:
- REPT 8
- movem.l D0-D6/A0-A5,-(A6) ;
- ENDM
- dbra D7,qdel_2
- movem.l D0-D6/A0-A5,-(A6) ;
- movem.l D0-D6/A0-A3,-(A6) ; (481*13+11)*4= 0x6130
- move.l #0x00020002,D2
- move.l d2,D0
- addq #1,d0 ;d0=0x00020003
- move.l next(PC),A6
- lea 2(a6),a6
- move.w #1023-1,d1
- islide6:
- REPT 4
- move.l D0,(a6)+
- add.l D2,D0
- ENDM
- dbra d1,islide6
- REPT 3
- move.l D0,(a6)+
- add.l D2,D0
- ENDM
- ;1023*4*2+3*2=
- move.w d3,(a6) ;next[DICSIZ - 1] = NIL;
- move.l #$01010101,D0 ;Wir brauchen einsen
- move.l d0,d1
- move.l d0,d2
- move.l d0,d3
- move.l d0,d4
- move.l d0,d5
- move.l d0,d6
- move.l d0,d7
- move.l d0,A0
- move.l d0,a1
- move.l d0,a2
- move.l d0,a3
- move.l d0,a4
- move.l d0,a5
- move.l level(PC),a6
- lea $2100(a6),a6
- movem.l D0-D7/A0-A5,-(A6) ;
- movem.l D0-D7/A0-A5,-(A6) ;
- movem.l D0-D7/A0-A5,-(A6) ;
- movem.l D0-D7/A0-A5,-(A6) ;
- movem.l D0-D7,-(A6) ; (4*14+8)*4=256
- movem.l (A7)+,D2-D7/A2-A6
- bsr start_huf
- rts
-
- ENDMOD
-
- DATA
-
- align.l
-
- level: dc.l 0
- position: dc.l 0
- next: dc.l 0
- prev: dc.l 0
- parent: dc.l 0
- pos: dc.w 0 ; !
- avail: dc.w 0 ; !
- childcount: dc.l 0 ; Reihenfolge !
- text: dc.l 0 ; !
- remainder: dc.l 0
- cpos: dc.w 0
- align.l
- printcount: dc.l 0
- ;+++++++++++++++++++++
- output_pos: dc.w 0
- align.l
- output_mask:dc.w 0
- align.l
- l_mpos: dc.w 0
- align.l
- st_save: dc.l 0 ;Zähler und Save
- my_cnt: dc.w 0 ;für Copy
- align.l
-
- END
-